/* $Header: rampgen.c,v 2.2 01/10/02 10:32:30 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:  rampgen.c - Ramp Generator                            */
/* ============                                                        */
/*                                                                     */
/* Author:  Susan Merkel                                               */
/*                                                                     */
/* MODULE PURPOSE:  This module contains the functions for generating  */
/*   ramps for the oven and small zones, and for generating ramps for  */
/*   flow and pressure programming.                                    */
/*                                                                     */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <error.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <ramps.h>
#include <iomap.h>
#include <i_op.h>
#include <leds.h>
#include <zone_config.h>
#include <zone_status.h>
#include <status.h>
#include <p_status.h>
#include <oven.h>
#include <run_ui.h>
#include <flow.h>
#include <p_ui.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/


/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/* Zone temperature information structures.                            */

RAMPINFO Oven_Temp_Info;

RAMPINFO Inja_Temp_Info;
RAMPINFO Injb_Temp_Info;

RAMPINFO Deta_Temp_Info;
RAMPINFO Detb_Temp_Info;

RAMPINFO Aux1_Temp_Info;
RAMPINFO Aux2_Temp_Info;

/* Column Pressure information structures.                             */

RAMPINFO Col1_Pres_Info;
RAMPINFO Col2_Pres_Info;

/* Aux Pressure information structures.                                */

RAMPINFO Aux3_Pres_Info;
RAMPINFO Aux4_Pres_Info;
RAMPINFO Aux5_Pres_Info;

/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/

/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/

/***********************************************************************/
/* FUNCTION:  Ramps                                                    */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:  This function is the entry point for the Ramp Generator,  */
/*           and is scheduled at a 50Hz frequency. When scheduled      */
/*           during the RUN_ACTIVE run state, it will update the run   */
/*           clock and generate setpoints for thermal, flow, and       */
/*           pressure ramps, if they exist.                            */
/*                                                                     */
/* RETURNED VALUE: None.                                               */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*               Run_State                                             */
/*               Run_Clock                                             */
/*               Active_Wkfile                                         */
/*               oven, zone, flow , pressure setpoints                 */
/*               ramp state variables                                  */
/*               pointer to temp., flow, pressure programs             */
/*                                                                     */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void Ramps(void)
{


   switch (Run_State)
   {

     case RUN_ACTIVE:     /* The GC is in the RUN_ACTIVE state.        */

         Run_Clock += TIME_INTERVAL;   /* Increment the Run_Clock           */


#define DO_A_RAMP(pRAMP_TABLE,pRAMP_INFO)                                       \
                                                                                \
         if ( (pRAMP_INFO)->ramp_enabled )                                      \
         {                                                                      \
             switch ( (pRAMP_INFO)->ramp_state)                                 \
             {                                                                  \
                 case INITIAL:                                                  \
                 case FINAL:     ProcessTime( (pRAMP_INFO) );                   \
                                 break;                                         \
                 case RAMP:      CalculateRamp( (pRAMP_INFO) );                 \
                                 break;                                         \
             }                                                                  \
         }


         DO_A_RAMP( &Active_Wkfile.oven_temp,     &Oven_Temp_Info )

         DO_A_RAMP( &Active_Wkfile.inja_temp,     &Inja_Temp_Info )
         DO_A_RAMP( &Active_Wkfile.injb_temp,     &Injb_Temp_Info )

         DO_A_RAMP( &Active_Wkfile.Column_1_Pres, &Col1_Pres_Info )
         DO_A_RAMP( &Active_Wkfile.Column_2_Pres, &Col2_Pres_Info )

         DO_A_RAMP( &Active_Wkfile.deta_temp,     &Deta_Temp_Info )
         DO_A_RAMP( &Active_Wkfile.detb_temp,     &Detb_Temp_Info )

         DO_A_RAMP( &Active_Wkfile.auxa_temp,     &Aux1_Temp_Info )
         DO_A_RAMP( &Active_Wkfile.auxb_temp,     &Aux2_Temp_Info )

         DO_A_RAMP( &Active_Wkfile.Aux_3_Pres,    &Aux3_Pres_Info )
         DO_A_RAMP( &Active_Wkfile.Aux_4_Pres,    &Aux4_Pres_Info )
         DO_A_RAMP( &Active_Wkfile.Aux_5_Pres,    &Aux5_Pres_Info )

         SetRampLEDS();      /* light the lights */

         /* Check to see if maximum run time exceeded. If so, stop the run. */

         if (( Run_Clock > MAX_RUN_TIME ) || ( Oven_Temp_Info.done ))
         {
             /* stop the run */
              StopRun(EndOvenRamp);
         }

         break;

     case POST_RUN:

         Oven_Temp_Info.done = TRUE;

         if ( Run_Clock < Active_Wkfile.post_time )
         {
              Run_Clock += TIME_INTERVAL;   /* Increment the Run_Clock          */

              if ( Oven_Temp_Info.ramp_state != POST )
              {
                  DoPostRunValues();

                  Oven_Temp_Info.ramp_state = POST;
                  Inja_Temp_Info.ramp_state = POST;
                  Injb_Temp_Info.ramp_state = POST;
                  Col1_Pres_Info.ramp_state = POST;
                  Col2_Pres_Info.ramp_state = POST;
                  Deta_Temp_Info.ramp_state = POST;
                  Detb_Temp_Info.ramp_state = POST;
                  Aux1_Temp_Info.ramp_state = POST;
                  Aux2_Temp_Info.ramp_state = POST;
                  Aux3_Pres_Info.ramp_state = POST;
                  Aux4_Pres_Info.ramp_state = POST;
                  Aux5_Pres_Info.ramp_state = POST;
              }
         }
         else /* Run_Clock >= Active_Wkfile.post_time */
         {
              if ( Oven_Temp_Info.ramp_state != INITIAL )
              {
                   SetInitValues();  /* also calls ResetRamps() */
              }

              /* stop the post run */
              StopRun(EndPostTime);
         }

         break;

     default: /* paranoid reinitialization ( stop pressed during isothermal run, post time, etc )  */

          if (( Oven_Temp_Info.ramp_state != INITIAL ) || ( Oven_Temp_Info.done ))
          {
               SetInitValues();  /* also calls ResetRamps() */
          }
     }

     /* Set flag that we have executed Ramps */
     Ramps_Executed = TRUE;
}



/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/

void SetRampLEDS(void)
{

   if (( Oven_Temp_Info.ramp_state == INITIAL ) &&
       ( Oven_Temp_Info.ramp_num == 0 ))
   {
//       TURN_INIT_TIME_LED_ON();
   }

   if ( Oven_Temp_Info.ramp_state == RAMP )
   {
//       TURN_RAMP_LED_ON();
   }

   if (( Oven_Temp_Info.ramp_state == FINAL ) &&
       ( Oven_Temp_Info.done == FALSE ))
   {
//       TURN_FINAL_LED_ON();
   }

}


/***********************************************************************/
/* FUNCTION:  CheckFinalTime                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:  This function is called from CalculateRamp when a ramp    */
/*           is done. It checks whether there is a final timem or not. */
/*           In either case, it goes on to check whether or not there  */
/*           is another ramp, and enters the appropriate state.        */
/*                                                                     */
/* RETURNED VALUE: None.                                               */
/*                                                                     */
/* GLOBALS USED: None.                                                 */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void CheckFinalTime( RAMPINFO *rampinfo)
{

  /* Check to see if the final time is zero. If it is, check to make   */
  /* sure we are not at the last ramp level. If we are, we just set    */
  /* ramp state to FINAL and will do nothing until the GC run is done. */
  /* If we are not at the last ramp level, see if there is another     */
  /* ramp. If there is, increment the ramp number for the next call to */
  /* the ramp generator. Doing this saves a call to the ramp generator */
  /* (in the FINAL state) with a final time of zero. If there is not   */
  /* another ramp, prepare to go to the FINAL state and do nothing.    */

  if (rampinfo->ramps[rampinfo->ramp_num].final_time == 0)
    {
      if (rampinfo->ramp_num + 1 < rampinfo->num_ramps )
        {
          if (rampinfo->ramps[rampinfo->ramp_num+1].rate > 0)
            {
              rampinfo->ramp_num++;
            }
          else
            {
              /* The next rate is zero. There are no more ramps, so    */
              /* go to FINAL and do nothing.                           */

              rampinfo->ramp_state = FINAL;
            }
         }
       else
         {
           /* Ramp limit has been reached. Go to FINAL and do nothing.*/

           rampinfo->ramp_state = FINAL;
           rampinfo->done = TRUE;
         }
    }
  else
    {
      /* There is a final time for the ramp. Update the check_time     */
      /* variable and enter the FINAL ramp state on the next call to   */
      /* the ramp generator.                                           */

      rampinfo->check_time = Run_Clock;
      rampinfo->ramp_state = FINAL;
    }
}



/***********************************************************************/
/* FUNCTION:  ProcessTime                                              */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: This function processes the "time" state for all of the    */
/*          thermal, pressure, and flow ramping for all of the zones,  */
/*          excluding the oven. It processes either the initial or     */
/*          final time. When the initial time has elapsed, the ramp    */
/*          state is entered if a ramp exists. When the final time has */
/*          elapsed, the run is stopped, unless there is another ramp  */
/*          to run.                                                    */
/*                                                                     */
/* RETURNED VALUE: None.                                               */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*               Run_Clock                                             */
/*                                                                     */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void ProcessTime(RAMPINFO *rampinfo)

{

   switch(rampinfo->ramp_state)
   {
     case INITIAL:

     /* Initial time is being processed.                               */

       /* If initial time has elapsed, see if a ramp exists. If so,    */
       /* prepare to enter ramp state next time ramp generator is      */
       /* called. If not, stay in INITIAL and do nothing.              */

       if (Run_Clock >= rampinfo->ramp_table->init_time)
       {
           if (rampinfo->ramps[rampinfo->ramp_num].rate > 0)
           {
               rampinfo->ramp_state = RAMP;
           }
           else
           {   /* there are not any ramps, just init time */

               if (rampinfo->ramp_table->init_time != 0)
               {
                   rampinfo->done = TRUE;
               }
               else
               {
                   /* run will stop when MAX_RUN_LENGTH is reached */
                   /* check is made in Ramps();                    */
               }
           }
       }

       break;

       case FINAL:

       /* Final time is being processed.                               */

         /* If final time has elapsed, check to see if there is another*/
         /* ramp. If so, prepare to enter the ramp state. If not,      */
         /* stay in FINAL and do nothing.                              */

         if (Run_Clock >= rampinfo->check_time +
                          rampinfo->ramps[rampinfo->ramp_num].final_time)
           {
             if ((rampinfo->ramp_num + 1 < rampinfo->num_ramps) &&
                 (rampinfo->ramps[rampinfo->ramp_num+1].rate > 0))
               {
                 rampinfo->ramp_state = RAMP;
                 rampinfo->ramp_num++;
               }
               else
               {
                 /* this was the last ramp */
                 rampinfo->done = TRUE;
               }
           }

       break;

   }
}



/***********************************************************************/
/* FUNCTION: CalculateRamp                                             */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: This function generates the setpoints for the thermal,     */
/*          flow, pressure, and velocity ramps for the small zones     */
/*          (Injector A and B, Detector A and B, Aux A and B).         */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*               Run_Clock                                             */
/*                                                                     */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void CalculateRamp(RAMPINFO *rampinfo )

{
  /* Check if the ramp is positive or negative.                        */

  if (rampinfo->ramps[rampinfo->ramp_num].final_value > (*(rampinfo->setpoint)))
    {
      *(rampinfo->setpoint)  += ( rampinfo->ramps[rampinfo->ramp_num].rate + rampinfo->remainder )
                                / rampinfo->rate_increment;
      rampinfo->remainder     = ( rampinfo->ramps[rampinfo->ramp_num].rate + rampinfo->remainder )
                                % rampinfo->rate_increment;

      /* Check to see if the ramp is done, i.e. if the setpoint has    */
      /* reached or exceeded the final value.                          */

      if (*(rampinfo->setpoint) >= rampinfo->ramps[rampinfo->ramp_num].final_value)
        {
          *(rampinfo->setpoint) = rampinfo->ramps[rampinfo->ramp_num].final_value;

          CheckFinalTime(rampinfo);
        }

    }
  else if (rampinfo->ramps[rampinfo->ramp_num].final_value < (*(rampinfo->setpoint)))
    {
      /* The ramp is negative. The setpoint is decremented in the      */
      /* while loop.                                                   */

      *(rampinfo->setpoint)  -= ( rampinfo->ramps[rampinfo->ramp_num].rate + rampinfo->remainder )
                                / rampinfo->rate_increment;
      rampinfo->remainder     = ( rampinfo->ramps[rampinfo->ramp_num].rate + rampinfo->remainder )
                                % rampinfo->rate_increment;

      /* Check to see if the ramp is done, i.e. if the setpoint is less*/
      /* than or equal to the final value.                             */

      if (*(rampinfo->setpoint) <= rampinfo->ramps[rampinfo->ramp_num].final_value)
        {
          *(rampinfo->setpoint) = rampinfo->ramps[rampinfo->ramp_num].final_value;

          CheckFinalTime(rampinfo);
        }

    }
  else
    {
      /* The final value is equal to the current setpoint. Start the  */
      /* final time for the ramp, if there is one.                    */

      CheckFinalTime(rampinfo);

    }
}



/***********************************************************************/
/* FUNCTION:  StartRunForRamps                                         */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:  This function initializes variables needed by the ramp    */
/*           generator at the start of a run. It is called by the      */
/*           StartRun function (in run_state.c).                       */
/*                                                                     */
/* RETURNED VALUE:  None.                                              */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                Oven_Temp_Info, Deta_Temp_Info                       */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void ResetRamps(void)
{

  /* REVISIT: May want to move this initialization to poweron and      */
  /* StopRun in order to speed up the StartRun function, which calls   */
  /* this.                                                             */

  /* The structures have a rate_increment field because the flow and   */
  /* pressure ramps will not use the same rate_increment as the oven   */
  /* and heated zones.                                                 */

  /* Initialize the structure for the oven ramp.                       */

  Oven_Temp_Info.ramp_state     = INITIAL;
  Oven_Temp_Info.ramp_num       = 0;
  Oven_Temp_Info.remainder      = 0;
  Oven_Temp_Info.rate_increment = ZONE_RATE_INC;
  Oven_Temp_Info.check_time     = 0;
  Oven_Temp_Info.done           = FALSE;


  /* Initialize the structure for the inlet thermal ramps            */

  Inja_Temp_Info.ramp_state     = INITIAL;
  Inja_Temp_Info.ramp_num       = 0;
  Inja_Temp_Info.remainder      = 0;
  Inja_Temp_Info.rate_increment = ZONE_RATE_INC;
  Inja_Temp_Info.check_time     = 0;
  Inja_Temp_Info.done           = FALSE;

  Injb_Temp_Info.ramp_state     = INITIAL;
  Injb_Temp_Info.ramp_num       = 0;
  Injb_Temp_Info.remainder      = 0;
  Injb_Temp_Info.rate_increment = ZONE_RATE_INC;
  Injb_Temp_Info.check_time     = 0;
  Injb_Temp_Info.done           = FALSE;


  /* Initialize the structure for the column ramps.                  */

  Col1_Pres_Info.ramp_state     = INITIAL;
  Col1_Pres_Info.ramp_num       = 0;
  Col1_Pres_Info.remainder      = 0;
  Col1_Pres_Info.rate_increment = PRES_RATE_INC;
  Col1_Pres_Info.check_time     = 0;
  Col1_Pres_Info.done           = FALSE;

  Col2_Pres_Info.ramp_state     = INITIAL;
  Col2_Pres_Info.ramp_num       = 0;
  Col2_Pres_Info.remainder      = 0;
  Col2_Pres_Info.rate_increment = PRES_RATE_INC;
  Col2_Pres_Info.check_time     = 0;
  Col2_Pres_Info.done           = FALSE;


  /* Initialize the structure for the detector thermal ramps         */

  Deta_Temp_Info.ramp_state     = INITIAL;
  Deta_Temp_Info.ramp_num       = 0;
  Deta_Temp_Info.remainder      = 0;
  Deta_Temp_Info.rate_increment = ZONE_RATE_INC;
  Deta_Temp_Info.check_time     = 0;
  Deta_Temp_Info.done           = FALSE;

  Detb_Temp_Info.ramp_state     = INITIAL;
  Detb_Temp_Info.ramp_num       = 0;
  Detb_Temp_Info.remainder      = 0;
  Detb_Temp_Info.rate_increment = ZONE_RATE_INC;
  Detb_Temp_Info.check_time     = 0;
  Detb_Temp_Info.done           = FALSE;



  /* Initialize the structure for the Aux thermal ramps              */

  Aux1_Temp_Info.ramp_state     = INITIAL;
  Aux1_Temp_Info.ramp_num       = 0;
  Aux1_Temp_Info.remainder      = 0;
  Aux1_Temp_Info.rate_increment = ZONE_RATE_INC;
  Aux1_Temp_Info.check_time     = 0;
  Aux1_Temp_Info.done           = FALSE;

  Aux2_Temp_Info.ramp_state     = INITIAL;
  Aux2_Temp_Info.ramp_num       = 0;
  Aux2_Temp_Info.remainder      = 0;
  Aux2_Temp_Info.rate_increment = ZONE_RATE_INC;
  Aux2_Temp_Info.check_time     = 0;
  Aux2_Temp_Info.done           = FALSE;


  /* Initialize the structure for the aux pressure ramps               */

  Aux3_Pres_Info.ramp_state     = INITIAL;
  Aux3_Pres_Info.ramp_num       = 0;
  Aux3_Pres_Info.remainder      = 0;
  Aux3_Pres_Info.rate_increment = PRES_RATE_INC;
  Aux3_Pres_Info.check_time     = 0;
  Aux3_Pres_Info.done           = FALSE;

  Aux4_Pres_Info.ramp_state     = INITIAL;
  Aux4_Pres_Info.ramp_num       = 0;
  Aux4_Pres_Info.remainder      = 0;
  Aux4_Pres_Info.rate_increment = PRES_RATE_INC;
  Aux4_Pres_Info.check_time     = 0;
  Aux4_Pres_Info.done           = FALSE;

  Aux5_Pres_Info.ramp_state     = INITIAL;
  Aux5_Pres_Info.ramp_num       = 0;
  Aux5_Pres_Info.remainder      = 0;
  Aux5_Pres_Info.rate_increment = PRES_RATE_INC;
  Aux5_Pres_Info.check_time     = 0;
  Aux5_Pres_Info.done           = FALSE;

}

/***********************************************************************/
/* FUNCTION: DoPostRunValues                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: This function is called in the POST_RUN state of Ramps()   */
/*          to generate post run values.                               */
/*                                                                     */
/* RETURNED VALUE:  None.                                              */
/*                                                                     */
/* GLOBALS USED:  Active_Wkfile                                        */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void DoPostRunValues()
{
  /* If the post time has not run out yet, download post run values.   */

         INTERRUPTS_OFF

         /* Set the zone temperature setpoints to the post value from the */
         /* workfile.                                                     */

         if ( Oven_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Oven_Table,Active_Wkfile.oven_temp.post_value);
         }



         if ( Inja_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Inja_Table,Active_Wkfile.inja_temp.init_value);
         }

         if ( Injb_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Injb_Table,Active_Wkfile.injb_temp.init_value);
         }

         if ( Deta_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Deta_Table,Active_Wkfile.deta_temp.init_value);
         }

         if ( Detb_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Detb_Table,Active_Wkfile.detb_temp.init_value);
         }

         if ( Aux1_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Auxa_Table,Active_Wkfile.auxa_temp.init_value);
         }

         if ( Aux2_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Auxb_Table,Active_Wkfile.auxb_temp.init_value);
         }

         if ( Aux3_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux3_Pres_Info.ramp_table->init_value, pAUX_3 );
         }

         if ( Aux4_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux4_Pres_Info.ramp_table->init_value, pAUX_4 );
         }

         if ( Aux5_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux5_Pres_Info.ramp_table->init_value, pAUX_5 );
         }



         SlamColumnSetpt( Col1_Pres_Info.ramp_table->post_value, pCOLUMN_1 );

         SlamColumnSetpt( Col2_Pres_Info.ramp_table->post_value, pCOLUMN_2 );

         INTERRUPTS_ON

}



/***********************************************************************/
/* FUNCTION: SetInitValues                                             */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: This function is called at the end of the POST_RUN state   */
/*          to generate initial values.                                */
/*                                                                     */
/* RETURNED VALUE:  None.                                              */
/*                                                                     */
/* GLOBALS USED:  Active_Wkfile                                        */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void SetInitValues()
{

          INTERRUPTS_OFF
          /* post time is over, set initial values */
         /* Set the zone temperature setpoints to the post value from the */
         /* workfile.                                                     */

         if ( Oven_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Oven_Table,Active_Wkfile.oven_temp.init_value);
         }

         SlamColumnSetpt( Col1_Pres_Info.ramp_table->init_value, pCOLUMN_1 );

         SlamColumnSetpt( Col2_Pres_Info.ramp_table->init_value, pCOLUMN_2 );

         if ( Inja_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Inja_Table,Active_Wkfile.inja_temp.init_value);
         }

         if ( Injb_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Injb_Table,Active_Wkfile.injb_temp.init_value);
         }

         if ( Deta_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Deta_Table,Active_Wkfile.deta_temp.init_value);
         }

         if ( Detb_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Detb_Table,Active_Wkfile.detb_temp.init_value);
         }

         if ( Aux1_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Auxa_Table,Active_Wkfile.auxa_temp.init_value);
         }

         if ( Aux2_Temp_Info.ramp_enabled )
         {
             JAM_TEMP_SETPT(&Auxb_Table,Active_Wkfile.auxb_temp.init_value);
         }

         if ( Aux3_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux3_Pres_Info.ramp_table->init_value, pAUX_3 );
         }

         if ( Aux4_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux4_Pres_Info.ramp_table->init_value, pAUX_4 );
         }

         if ( Aux5_Pres_Info.ramp_enabled )
         {
             SlamAuxPresSetpt( Aux5_Pres_Info.ramp_table->init_value, pAUX_5 );
         }


         ResetRamps();

         INTERRUPTS_ON

}
